<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

/** 无需登录 */
Route::namespace('Home')->middleware('web')->group(function () {
    Route::get('/', 'IndexController@index');   // 首页
    Route::get('/article', 'ArticleController@record')->name('article');   // 文章归档
    Route::get('/article/{id}', 'ArticleController@detail');   // 文章详情
    Route::get('/search', 'IndexController@search')->name('search');    // 搜索列表页
    Route::get('/category/{id}', 'IndexController@category'); // 分类列表页面
    Route::get('/tag/{id}', 'IndexController@tag');    // 标签列表页

    Route::get('/loginForm', 'EntryController@showLoginForm');    // 登录视图
    Route::get('/registerForm', 'RegisterController@showRegistrationForm');    // 注册视图
    Route::get('/resetPwdForm', 'ResetPasswordController@showResetPwdForm');    // 重置密码视图
    Route::post('/login', 'EntryController@login');    // 登录
    Route::post('/register', 'RegisterController@register');    // 注册
    Route::post('/resetPwd', 'ResetPasswordController@reset');    // 重置密码

    // 三方登录
    Route::get('/oauth/github', 'AuthController@redirectToProvider');
    Route::get('/oauth/github/callback', 'AuthController@handleProviderCallback');
});

/** 需要登录 */
Route::namespace('Home')->middleware(['web', 'member_pass'])->group(function () {
    Route::post('/article/{id}/comment', 'ArticleController@comment');   // 评论
    Route::get('/logout', 'EntryController@logout');   // 退出登录
    Route::post('/comment/submit', 'CommentController@submit')->name('comment');    // 评论
    Route::post('/link', 'LinkController@submit')->name('link');    // 申请友链
});